package com.csx.base.design.behavior.template;

import java.util.Random;

/**
 * @author cuisongxu
 * @date 2022/9/26 12:04
 */
public class HRProject extends PM{

    private Random random = new Random();

    @Override
    public String analyze() {
        System.out.println("分析师: 需求分析");
        return "人力资源管理系统需求";
    }

    @Override
    public String design(String project) {
        System.out.println("架构师: 程序设计...");

        return "设计(" + project + ")";
    }

    @Override
    public String develop(String project) {

        // 修复bug
        if(project.contains("bug")) {
            System.out.println("开发: 修复bug...");
            project = project.replace("bug", "");
            project = "修复 (" + project + ")";

            if(random.nextBoolean()) {
                project += "bug"; // 可能会引起另外一个bug
            }
            return project;
        }

        // 开发系统功能
        System.out.println("开发: 写代码...");
        if(random.nextBoolean()) {
            // 可能会产生bug
            project += "bug";
        }

        return "开发 (" + project + ")";
    }

    @Override
    public boolean test(String project) {

        if(project.contains("bug")) {
            System.out.println("测试: 发现bug");
            return false;
        }

        System.out.println("测试: 用例通过...");

        return true;
    }

    @Override
    public void release(String project) {

        System.out.println("运维: 上线发布...");
        System.out.println("=================================最终产品====================");
        System.out.println(project);
        System.out.println("============================================================");

    }
}
